<?php

namespace Datacore\Utils;

class DataGridView
{
    
    private static $code = 0;
    private static $msg = "";
    private static $count = 0;
    private static $data = array();
    
    
    public static function listView($data,$totle,$msg)
    {
        self::$data = $data;
        self::$count = $totle;
        self::$msg   = $msg;
       return self::result( json_encode(
            array(
                'code'=> self::$code,
                'count'=> self::$count,
                'data' => self::$data,
                'msg'  => self::$msg
            )
        ));
    }
    
    public static function successsView($msg)
    {
        self::$msg   = $msg;
        return self::result(json_encode(
            array(
                'code'=> self::$code,
                'msg'  => self::$msg
            )
        ));
    }
    
    public static function errorView($code,$msg)
    {
        self::$code  = $code;
        self::$msg   = $msg;
        return self::result(json_encode(
            array(
                'code'=> self::$code,
                'msg'  =>self::$msg
            )
        ));
    }
    
    public static function result($json)
    {
        exit($json);
    }
}